function getIndexFromDomOrString(html) {
  if(typeof html !== 'string' && !(html instanceof Document) && !(html instanceof Node)) {
    console.warn(`getIndexFromDomString: html-${html} is not a string return []`);
    return [];
  }
  let dom;
  if(typeof html === 'string') {
    let domParser = new DOMParser();
    dom = domParser.parseFromString(html, 'text/html');
  } else {
    dom = html;
  }
  let res = [];
  dom.childNodes.forEach(node => {
    if(node.tagName.startsWith('H')) {
      res.push({
        level: parseInt(node.tagName.slice(1)) - 1,
        title: node.innerText,
        element: node
      })
    }
  })
  return res;
}

export {
  getIndexFromDomOrString
}